<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QNetworkCookieJar Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="../pyqt4ref.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QNetworkCookieJar Class Reference<br /><sup><sup>[<a href="qtnetwork.html">QtNetwork</a> module]</sup></sup></h1><p>The QNetworkCookieJar class implements a simple jar of <a href="qnetworkcookie.html">QNetworkCookie</a> objects <a href="#details">More...</a></p>
<p>Inherits <a href="qobject.html">QObject</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qnetworkcookiejar.html#QNetworkCookieJar">__init__</a></b> (<i>self</i>, QObject&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" />list-of-QNetworkCookie <b><a href="qnetworkcookiejar.html#allCookies">allCookies</a></b> (<i>self</i>)</li><li><div class="fn" />list-of-QNetworkCookie <b><a href="qnetworkcookiejar.html#cookiesForUrl">cookiesForUrl</a></b> (<i>self</i>, QUrl)</li><li><div class="fn" /><b><a href="qnetworkcookiejar.html#setAllCookies">setAllCookies</a></b> (<i>self</i>, list-of-QNetworkCookie)</li><li><div class="fn" />bool <b><a href="qnetworkcookiejar.html#setCookiesFromUrl">setCookiesFromUrl</a></b> (<i>self</i>, list-of-QNetworkCookie, QUrl)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QNetworkCookieJar class implements a simple jar of <a href="qnetworkcookie.html">QNetworkCookie</a> objects</p>
<p>Cookies are small bits of information that stateless protocols like HTTP use to maintain some persistent information across requests.</p>
<p>A cookie is set by a remote server when it replies to a request and it expects the same cookie to be sent back when further requests are sent.</p>
<p>The cookie jar is the object that holds all cookies set in previous requests. Web browsers save their cookie jars to disk in order to conserve permanent cookies across invocations of the application.</p>
<p>QNetworkCookieJar does not implement permanent storage: it only keeps the cookies in memory. Once the QNetworkCookieJar object is deleted, all cookies it held will be discarded as well. If you want to save the cookies, you should derive from this class and implement the saving to disk to your own storage format.</p>
<p>This class implements only the basic security recommended by the cookie specifications and does not implement any cookie acceptance policy (it accepts all cookies set by any requests). In order to override those rules, you should reimplement the <a href="qnetworkcookiejar.html#cookiesForUrl">cookiesForUrl</a>() and <a href="qnetworkcookiejar.html#setCookiesFromUrl">setCookiesFromUrl</a>() virtual functions. They are called by <a href="qnetworkreply.html">QNetworkReply</a> and <a href="qnetworkaccessmanager.html">QNetworkAccessManager</a> when they detect new cookies and when they require cookies.</p>
<p>See also <a href="qnetworkcookie.html">QNetworkCookie</a>, <a href="qnetworkaccessmanager.html">QNetworkAccessManager</a>, <a href="qnetworkreply.html">QNetworkReply</a>, <a href="qnetworkrequest.html">QNetworkRequest</a>, and <a href="qnetworkaccessmanager.html#setCookieJar">QNetworkAccessManager.setCookieJar</a>().</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QNetworkCookieJar" />QNetworkCookieJar.__init__ (<i>self</i>, <a href="qobject.html">QObject</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Creates a <a href="qnetworkcookiejar.html">QNetworkCookieJar</a> object and sets the parent object to be <i>parent</i>.</p>
<p>The cookie jar is initialized to empty.</p>
<a name="//apple_ref/cpp/instm/QNetworkCookieJar/~QNetworkCookieJar" />
<h3 class="fn"><a name="allCookies" />list-of-QNetworkCookie QNetworkCookieJar.allCookies (<i>self</i>)</h3><p>Returns all cookies stored in this cookie jar. This function is suitable for derived classes to save cookies to disk, as well as to implement cookie expiration and other policies.</p>
<p>See also <a href="qnetworkcookiejar.html#setAllCookies">setAllCookies</a>() and <a href="qnetworkcookiejar.html#cookiesForUrl">cookiesForUrl</a>().</p>
<a name="//apple_ref/cpp/instm/QNetworkCookieJar/cookiesForUrl" />
<h3 class="fn"><a name="cookiesForUrl" />list-of-QNetworkCookie QNetworkCookieJar.cookiesForUrl (<i>self</i>, <a href="qurl.html">QUrl</a>)</h3><p>Returns the cookies to be added to when a request is sent to <i>url</i>. This function is called by the default <a href="qnetworkaccessmanager.html#createRequest">QNetworkAccessManager.createRequest</a>(), which adds the cookies returned by this function to the request being sent.</p>
<p>If more than one cookie with the same name is found, but with differing paths, the one with longer path is returned before the one with shorter path. In other words, this function returns cookies sorted by path length.</p>
<p>The default <a href="qnetworkcookiejar.html">QNetworkCookieJar</a> class implements only a very basic security policy (it makes sure that the cookies' domain and path match the reply's). To enhance the security policy with your own algorithms, override cookiesForUrl().</p>
<p>See also <a href="qnetworkcookiejar.html#setCookiesFromUrl">setCookiesFromUrl</a>() and <a href="qnetworkaccessmanager.html#setCookieJar">QNetworkAccessManager.setCookieJar</a>().</p>
<a name="//apple_ref/cpp/instm/QNetworkCookieJar/setAllCookies" />
<h3 class="fn"><a name="setAllCookies" />QNetworkCookieJar.setAllCookies (<i>self</i>, list-of-QNetworkCookie)</h3><p>Sets the internal list of cookies held by this cookie jar to be <i>cookieList</i>. This function is suitable for derived classes to implement loading cookies from permanent storage, or their own cookie acceptance policies by reimplementing <a href="qnetworkcookiejar.html#setCookiesFromUrl">setCookiesFromUrl</a>().</p>
<p>See also <a href="qnetworkcookiejar.html#allCookies">allCookies</a>() and <a href="qnetworkcookiejar.html#setCookiesFromUrl">setCookiesFromUrl</a>().</p>
<a name="//apple_ref/cpp/instm/QNetworkCookieJar/setCookiesFromUrl" />
<h3 class="fn"><a name="setCookiesFromUrl" />bool QNetworkCookieJar.setCookiesFromUrl (<i>self</i>, list-of-QNetworkCookie, <a href="qurl.html">QUrl</a>)</h3><p>Adds the cookies in the list <i>cookieList</i> to this cookie jar. Default values for path and domain are taken from the <i>url</i> object.</p>
<p>Returns true if one or more cookes are set for url otherwise false.</p>
<p>If a cookie already exists in the cookie jar, it will be overridden by those in <i>cookieList</i>.</p>
<p>The default <a href="qnetworkcookiejar.html">QNetworkCookieJar</a> class implements only a very basic security policy (it makes sure that the cookies' domain and path match the reply's). To enhance the security policy with your own algorithms, override setCookiesFromUrl().</p>
<p>Also, <a href="qnetworkcookiejar.html">QNetworkCookieJar</a> does not have a maximum cookie jar size. Reimplement this function to discard older cookies to create room for new ones.</p>
<p>See also <a href="qnetworkcookiejar.html#cookiesForUrl">cookiesForUrl</a>() and <a href="qnetworkaccessmanager.html#setCookieJar">QNetworkAccessManager.setCookieJar</a>().</p>
<p /><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;snapshot-4.7.1-5014f7c72a58 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2010</td><td align="right" width="25%">Qt&#160;4.6.1</td></tr></table></div></address></body></html>